package com.stm.bi.web;

import com.stm.bi.dto.cmd.SubjectCategoryAdd;
import com.stm.bi.dto.cmd.SubjectCategoryUpd;
import com.stm.bi.dto.query.SubjectCategoryTreeQry;
import com.stm.bi.dto.vo.SubjectCategoryVO;
import com.stm.bi.dto.vo.SubjectCategoryTreeVO;
import com.stm.bi.service.SubjectCategoryService;
import com.stm.framework.annotation.Module;
import com.stm.framework.annotation.ReqParam;
import com.stm.framework.annotation.RestApi;
import com.stm.framework.dto.Response;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
* 科目分类-controller服务
*
* @author qinyongjie
* @date 2025-05-22
*/
@RestController
@RequestMapping("/subjectCategory")
@Module("科目分类")
public class SubjectCategoryController {
    @Resource
    private SubjectCategoryService subjectCategoryService;

    /**
     * 科目分类树查询
     */
    @GetMapping(value = "/tree")
    @RestApi(name = "科目分类树查询", author = "qinyongjie", idx=1)
    public Response<List<SubjectCategoryTreeVO>> selectTree(SubjectCategoryTreeQry qry) {
        return subjectCategoryService.selectTree(qry);
    }

    /**
    * 科目分类详细查询
    */
    @GetMapping(value = "/{id}")
    @RestApi(name = "科目分类详细查询", author = "qinyongjie", idx=2)
    public Response<SubjectCategoryVO> selectById(@PathVariable("id") @ReqParam(label = "id",required = true) Long id) {
        return subjectCategoryService.selectById(id);
    }

    /**
    * 科目分类新增
    */
    @PostMapping(value = "/create")
    @RestApi(name = "新增科目分类", author = "qinyongjie", idx=3)
    public Response create(@RequestBody SubjectCategoryAdd subjectCategoryAdd) {
        return subjectCategoryService.create(subjectCategoryAdd);
    }

    /**
    * 科目分类更新
    */
    @PutMapping(value = "/update")
    @RestApi(name = "更新科目分类", author = "qinyongjie", idx=4)
    public Response update(@RequestBody SubjectCategoryUpd subjectCategoryUpd) {
        return subjectCategoryService.update(subjectCategoryUpd);
    }
}